#pragma once
#include "refc_ptr.h"
#include "widget.h"
#include "window.h"

namespace krryn{
namespace gui{
	template<typename _RenderTag>
	class render_control : public widget{
	public:
		// no other typedefs because we're abstract

		void activate();
		void swap_buffers();
		virtual void* handle() = 0;
	};

	template<typename _RenderTag, typename _Parent>
	class render_control_initializer : public widget_initializer<_Parent>{
	public:
		render_control_initializer() 
			: m_Fullscreen(false), m_BitsPerPixel(32) {}

		render_control_initializer &fullscreen(bool a_Fullscreen){
			m_Fullscreen = a_Fullscreen;
			return *this;
		}

		render_control_initializer &bits_per_pixel(unsigned int a_BitsPerPixel){
			m_BitsPerPixel = a_BitsPerPixel;
			return *this;
		}

		typename render_control<_RenderTag>* create(){
			if(get_parent() == 0){
				// create a default window if we have none
				parent(window::with()
						.width(get_width())
						.top(get_top())
						.left(get_left())
						.height(get_height())
					.create());

				// reset the top and left position because it doesn't make sense
				// to use it for both the window and this control
				top(0);
				left(0);
			}

			return new render_control<_RenderTag>(static_cast<_Parent&>(*this));
		}

		unsigned int m_BitsPerPixel;
		bool m_Fullscreen;
	};
}
}